
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>如何提高 ES集群的查询性能和吞吐量？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>如何提高 ES集群的查询性能和吞吐量？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">配置</div>
          <div class="card-question">在优化Elasticsearch硬件资源时，关于JVM堆内存的配置有什么通用建议？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">配置</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通常建议将Elasticsearch节点的JVM堆内存设置为物理内存的50%，但总大小不应超过32GB。</div>
          </div>
          <div class="card-source">来源: 1. 硬件资源优化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">为什么在部署Elasticsearch时推荐使用固态硬盘（SSD）而不是传统的机械硬盘（HDD）？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为SSD能提供更快的数据访问速度和更低的延迟，这有助于显著提高磁盘 I/O 性能。</div>
          </div>
          <div class="card-source">来源: 1. 硬件资源优化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">增加索引的分片(Shard)和副本(Replica)数量分别对查询性能有什么影响？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">增加分片数量可以并行处理更多查询请求，但过多会增加管理开销。增加副本数可以提高查询的并发处理能力，但会增加数据存储和写入的负担。</div>
          </div>
          <div class="card-source">来源: 2. 索引设计优化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">在Elasticsearch的索引映射（Mapping）中，为什么进行聚合操作时推荐使用`keyword`类型而不是`text`类型？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">文档建议，为了优化性能，应尽量避免使用`text`类型的字段进行聚合操作，而应该使用`keyword`类型的字段。</div>
          </div>
          <div class="card-source">来源: 2. 索引设计优化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">优化</div>
          <div class="card-question">Elasticsearch中常见的“深度分页”问题是什么？文档推荐了哪两种API来解决这个问题？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">优化</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">深度分页会导致大量的I/O操作，性能低下。文档建议使用 `search_after` 或 `scroll` API来处理大量数据的分页需求。</div>
          </div>
          <div class="card-source">来源: 3. 查询优化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">优化</div>
          <div class="card-question">在设计Elasticsearch查询语句时，为什么推荐使用`filter`上下文而非`query`上下文？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">优化</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">因为`filter`上下文不会计算相关性分数（relevance score），所以其查询效率比`query`上下文更高。</div>
          </div>
          <div class="card-source">来源: 5. 查询设计</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">为了优化集群配置，Elasticsearch的节点可以分为哪些不同角色？协调节点和数据节点的主要职责是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">节点可以分为主节点、数据节点、协调节点等。数据节点专注于数据存储和查询处理，而协调节点则负责处理查询请求的路由和结果聚合。</div>
          </div>
          <div class="card-source">来源: 4. 集群配置和管理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">Elasticsearch利用了哪些缓存机制来提高重复查询的性能？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Elasticsearch利用查询缓存（query cache）和字段数据缓存（field data cache）来提高查询性能，这些缓存对于重复性查询尤其有效。</div>
          </div>
          <div class="card-source">来源: 3. 查询优化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">如何优化Elasticsearch查询以减少网络传输的数据量，从而提升性能？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过在查询中只检索需要的字段，避免返回大量不必要的字段数据。这可以通过`_source`参数来指定返回的字段列表实现。</div>
          </div>
          <div class="card-source">来源: 5. 查询设计</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
